<template>
  <div class="policy-query-form">
    <el-form ref="form" :model="formParams" :inline="true">
      <el-form-item prop="name">
        <el-input
          v-model="formParams.title"
          placeholder="政策标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item prop="level">
        <el-select v-model="formParams.level" placeholder="政策级别" clearable>
          <el-option
            v-for="level in childrenOption[0]"
            :key="level.value"
            :label="level.desc"
            :value="level.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item prop="type">
        <el-select v-model="formParams.type" placeholder="政策类型" clearable>
          <el-option
            v-for="dict in childrenOption[1]"
            :key="dict.value"
            :label="dict.desc"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="handleQuery">查询</el-button>
        <el-button type="warning" @click="handleReset">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'PolicyQuery',
  props: { childrenOption: Array },
  data() {
    return {
      formParams: {
        title: '',
        level: '',
        type: '',
      },
    }
  },
  methods: {
    handleQuery() {
      this.$emit('query', this.formParams)
    },
    handleReset() {
      this.$refs['form'].resetFields()
      this.handleQuery()
    },
  },
  mounted() {
    console.log(this.childrenOption)
  },
}
</script>

<style lang="scss" scoped>
</style>
